<layout name ="common" />
<script type="text/javascript" charset="utf-8" src="__PLUGINS__/kindeditor/kindeditor.js"></script>
<script type="text/javascript" charset="utf-8" src="__PLUGINS__/kindeditor/lang/zh_CN.js"></script>
<script>
	KindEditor.ready(function(K) {
			window.editor = K.create('#editor_id');
	});
</script>
<div class="templatemo-content-widget white-bg">
	<h2 class="margin-bottom-10 templatemo-blue-button">
		<if condition='isset($artInfo)'>
			编辑文章
		<else />
			发布新文章
		</if>
		<a style="color: #FFF; font-size: 20px; display: inline-block; margin-left: 100px;" href="javascript:void(0)" onclick="history.back()" class="templatemo-is-btn">返回</a>
	</h2>
	<form action="__ROOT__/article/addArticle<if condition='isset($artInfo)'>/id/{$artInfo.id}</if>" class="templatemo-login-form" method="post" enctype="multipart/form-data">
		<div class="row form-group">
			<div class="col-lg-12">
				<img id="seeNow" src="
					<if condition='isset($artInfo)'>
						__ROOT__/{$artInfo.bigimg}
					<else />
						__HOME__/images/addart.jpg
					</if>
				" style="width: 100%;">
			</div>
		</div>
		<div class="row form-group">
			<div class="col-lg-6 col-md-6 form-group">
				<label class="control-label templatemo-block">选择文章图片<span>  宽高比  1:0.333  </span></label>
				<input type="file" name="artImg" id="file" class="filestyle" data-buttonName="btn-primary" data-buttonBefore="true" data-icon="false">
				<p>文件最大支持 2 MB.</p>
			</div>
			<div class="col-lg-6 col-md-6 form-group">
				<label class="control-label templatemo-block">选择分类</label>
				<select class="form-control" name="cateid">
				<foreach name='res' item='k'>
					<if condition='$artInfo.cate eq $k["cate"]'>
						<option value="{$k.id}" selected>{$k.cate}</option>
					<else />
						<option value="{$k.id}">{$k.cate}</option>
					</if>
				</foreach>
				</select>
			</div>
		</div>
		<div class="row form-group">
			<div class="col-lg-6 col-md-6 form-group">
				<label for="title">文章标题</label>
				<input type="text" class="form-control" id="title" placeholder="输入标题" name="title" value="<if condition='isset($artInfo)'>{$artInfo.title}</if>">
			</div>
			<div class="col-lg-6 col-md-6 form-group">
				<label for="author">作者</label>
				<input type="text" class="form-control" id="author" placeholder="作者" name="author" value="<if condition='isset($artInfo)'>{$artInfo.author}</if>">
			</div>
		</div>
		<div class="row form-group">
			<div class="col-lg-12 has-success form-group">
				<label class="control-label" for="profiles">文章简介</label>
				<textarea rows="3" class="form-control" id="profiles" name="profiles"><if condition='isset($artInfo)'>{$artInfo.profiles}</if></textarea>
			</div>
		</div>
		<div class="row form-group">
			<div class="col-lg-12">
				<label class="control-label" for="content">文章内容</label>
				<textarea style="width: 100%;" rows="20" class="form-control" id="editor_id" name="content"><if condition='isset($artInfo)'>{$artInfo.content}</if></textarea>
			</div>
		</div>
		<div class="form-group text-center">
			<div class="margin-right-15 templatemo-inline-block">
				<if condition='isset($artInfo) AND ($artInfo.is_home eq 1)'>
					<input type="checkbox" name="is_home" id="c4" value="1" checked="checked">
				<else />
					<input type="checkbox" name="is_home" id="c4" value="1">
				</if>
				<label for="c4" class="font-weight-400"><span></span>首页显示</label>
			</div>
			<div class="margin-right-15 templatemo-inline-block">
				<if condition='isset($artInfo) AND ($artInfo.is_top eq 1)'>
					<input type="checkbox" name="is_top" id="c5" value="1" checked="checked">
				<else />
					<input type="checkbox" name="is_top" id="c5" value="1">
				</if>
				<label for="c5" class="font-weight-400"><span></span>置顶</label>
			</div>
			<button type="submit" class="templatemo-blue-button">发布</button>
			<button type="reset" class="templatemo-white-button">重置</button>
		</div>
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		$("#leftMenu a[class='active']").removeClass("active");
		$('#leftMenu a:eq(1)').addClass("active");
	});
	$("#file").change(function (){
		var file = this.files[0];
		url = window.URL.createObjectURL(file);
		$("#seeNow").attr('src',url);
		var width = $("#seeNow").width() * 0.333;
		$("#seeNow").height(width);
	});
	$('button[type="reset"]').click(function () {
		$("#seeNow").attr('src','__HOME__/images/nivoslider1.jpg');
	})
</script>